class CreateDocuments < ActiveRecord::Migration
  def self.up
    create_table :documents do |t|
      # A number that has physical meaning
      # e.g. aya number or hadith number
      t.integer :document_no

      # Type of this document (for STI)
      # e.g Aya or Sura
      t.string :type

      # used for ordering
      t.integer :position

      # The section in where this document is located
      t.integer :section_id
      # Hadith or Aya main text
      t.text :body
      
      # Description (shar7)
      t.text :description, :limit=>1.megabyte

      # Rewaya (in Hadith)
      t.text :rewaya
      # Quarter number (for aya)
      t.integer :quarter_no
      # Daraget El Se77a
      t.text :sanad
      t.timestamps
    end
    
    add_index :documents, :section_id
  end

  def self.down
    drop_table :documents
  end
end
